import { AccountDao } from "../account_server/dao/AccountDao";
import { RoomResultDao } from "../hall_server/dao/RoomResultDao";
import { RoomVideoDao } from "../hall_server/dao/RoomVideoDao";
import { ChargeDao } from "../pay_server/dao/ChargeDao";
import { Config } from "../src/config/Config";
import DateUtil from "../src/engine/utils/DateUtil";
import { Logger } from "../src/engine/utils/Logger";
import { ClubTopDao } from "./dao/ClubTopDao";
import { Club_Freeze_HistoryDao } from "./dao/Club_Freeze_HistoryDao";
import { Club_HistoryDao } from "./dao/Club_HistoryDao";
import { Daily_ResourceDao } from "./dao/Daily_ResourceDao";
import { User_Coins_HistoryDao } from "./dao/User_Coins_HistoryDao";
import { User_Gems_HistoryDao } from "./dao/User_Gems_HistoryDao";
import { User_Spend_DailyDao } from "./dao/User_Spend_DailyDao";

const check_Day_Inteval: number = 1000 * 60 * 60 * 24;//1天检查一次
const check_HalfHour_Inteval: number = 1000 * 60 * 30;//30天检查一次

export class LogAddManager {

    public static instance: LogAddManager = new LogAddManager();

    private last_check_day_time: number = 0
    private last_check_halfHour_time: number = 0

    public checkDayLog(now: number) {
        this.checkAddDayLog(now)
        this.checkAddHalfHourLog(now)
    }

    private checkAddDayLog(now: number) {
        if (now - this.last_check_day_time >= check_Day_Inteval) {
            let date: Date = new Date()
            // Logger.log("checkAddDayLog=", date.getHours())
            if (date.getHours() == 0) { //你见过半夜5点的篮球吗？
                this.last_check_day_time = now;
                // Daily_ResourceDao.insert_daily_resource()
            }
        }
    }


    private checkAddHalfHourLog(now: number) {
        if (now - this.last_check_halfHour_time >= check_HalfHour_Inteval) {
            let date: Date = new Date()
            // if (date.getMinutes() % 30 == 0) { //半小时搞一次
                this.last_check_halfHour_time = now;
                AccountDao.checkAddDailyLogin(date)
                AccountDao.checkAddDailyRegister(date)
            // }
        }
    }


}